﻿using de.wolfmarco.pas.Accounting.Database;
using de.wolfmarco.pas.Accounting.MVVM;
using de.wolfmarco.pas.Shared.Database;
using de.wolfmarco.pas.Shared.MessageBoxes;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace de.wolfmarco.pas.Accounting.Database
{
    public class AccountingDatabase
    {
        public AccountingDatabase()
        {
            using ( AccountingDbContext db = new AccountingDbContext() )
            {
                try
                {
                    //db.Database.Initialize(true);
                    //db.Database.CreateIfNotExists();
                    db.SaveChanges();

                    ScheduledCashFlow cashFlow = new ScheduledCashFlow();
                    cashFlow.AmountOfMoney = 100;
                    cashFlow.Direction = CashFlowDirectionEnum.Income;
                    cashFlow.EndDate = null;
                    cashFlow.Id = Guid.NewGuid();
                    cashFlow.Loop = CashFlowLoopEnum.Daily;
                    cashFlow.Rhythm = CashFlowRhythmEnum.StartDate;
                    cashFlow.StartDate = new DateTime(2014, 7, 1);
                    cashFlow.Description = "Beschreibung";

                    db.ScheduledCashFlowList.Add(cashFlow);
                    db.SaveChanges();
                }
                catch (Exception exc)
                {
                    PASMessageBox.ShowException(exc);
                }
            }
        }
    }
}
